/**  
 * All rights Reserved, Designed By <a href="www.itttq.com" target="_blank">www.itttq.com</a>
 * @date:   2017-07-21 11:42:21
 * @Copyright: 2017 <a href="www.itttq.com" target="_blank">www.itttq.com</a> Inc. All rights reserved. 
 */
package com.itttq.gshop.pbpm.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.itttq.gshop.domain.po.WareInfoPo;
import com.itttq.gshop.domain.to.IndexStatTo;
import com.itttq.gshop.domain.to.ResultPageTo;
import com.itttq.gshop.pbpm.mapper.IWareInfoMapper;

@Service
public class WareInfoService {
	@Autowired
	private IWareInfoMapper wareInfoMapper;
	
	/**
	 * 根据ID获取WareInfoPo对象
	 * 
	 * @param id
	 * @return
	 * @Author 迷蝶
	 * @return WareInfoPo
	 */
	public WareInfoPo getWareInfo(int id) {
		return wareInfoMapper.findWareInfoById(id);
	}
	
	/**
	 * 根据条件获取WareInfoPo对象，不返回查询的数据总数
	 * 
	 * @param wareInfo
	 * @Author 迷蝶
	 * @return List<WareInfoPo>
	 */
	public List<WareInfoPo> getWares(WareInfoPo wareInfo) {
		return wareInfoMapper.findWareInfos(wareInfo);
	}
	
	/**
	 * 根据条件获取WareInfoPo对象，并返回查询的数据总数
	 * 
	 * @param wareInfo
	 * @Author 迷蝶
	 * @return ResultPageTo<WareInfoPo>
	 */
	public ResultPageTo<WareInfoPo> getWareInfos(WareInfoPo wareInfo) {
		return new ResultPageTo<WareInfoPo>(wareInfo.getStart(), wareInfo.getSize(), 
				wareInfoMapper.findWareInfoCount(wareInfo), wareInfoMapper.findWareInfos(wareInfo));
	}
	
	/**
	 * 根据ID删除WareInfoPo对象
	 * 
	 * @param id
	 * @Author 迷蝶
	 */
	public Integer delWareInfo(int id) {
		return wareInfoMapper.delWareInfoById(id);
	}
	
	/**
	 * 增加WareInfoPo对象
	 * 
	 * @param wareInfo
	 * @Author 迷蝶
	 */
	public Integer addWareInfo(WareInfoPo wareInfo) {
		return wareInfoMapper.addWareInfo(wareInfo);
	}
	
	/**
	 * 根据条件更新WareInfoPo对象
	 * 
	 * @param wareInfo
	 * @Author 迷蝶
	 */
	public Integer updateWareInfo(WareInfoPo wareInfo) {
		// TODO GXG 修改价格时，修改购物车和收藏商品的价格和积分
		return wareInfoMapper.updateWareInfo(wareInfo);
	}

	/**
	 * 获取今天新增商品
	 * 
	 * @Author 迷蝶
	 * @return IndexStatTo
	 */
	public IndexStatTo getWareCountToday() {
		return wareInfoMapper.findWareCountToday();
	}
}
